package com.promis.party.ui.home.homebanner.mylearn;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.promis.party.R;
import com.promis.party.helper.ContextHelper;

import java.util.List;

/**
 * Created by jidanbo on 2018/2/4.
 */

public class ExamTotalListAdapter extends RecyclerView.Adapter<ExamTotalListAdapter.ViewHolder> {

    private Context context;
    private ContextHelper contextHelper;
    private OnItemClickListener onItemClickListener;
//    private List<Store> storeList;

    public ExamTotalListAdapter(Context context) {
        this.context = context;
        contextHelper = new ContextHelper(context);
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(context).inflate(R.layout.adapter_exam_total, parent, false);
        return new ViewHolder(context, view, onItemClickListener);
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
//        if (CollectionUtils.isNullOrEmpty(storeList)) return;
    }

    @Override
    public int getItemCount() {
//        if (CollectionUtils.isNullOrEmpty(storeList)) return 0;
//        else return storeList.size();
        return 3;
    }

    public void setOnItemClickListener(OnItemClickListener onItemClickListener) {
        this.onItemClickListener = onItemClickListener;
    }

    public void notifyDataSetChanged(List<String> storeList) {
//        this.storeList = storeList;
        super.notifyDataSetChanged();
    }

    final class ViewHolder extends RecyclerView.ViewHolder {

        public ViewHolder(final Context context, View view, final OnItemClickListener onItemClickListener) {
            super(view);

            view.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    if (onItemClickListener != null)
                        onItemClickListener.onItemClick(v, getLayoutPosition());
                }
            });
        }
    }

    public static interface OnItemClickListener {
        void onItemClick(View v, int position);
    }
}
